var $ = require("../../utils/Ajax.js");
Page({
  data: {
    Id: null,
    CommentCont: null
  },

  onLoad: function (options) {
    this.setData({
      Id: options.Id
    })
  },

  // 输入评论内容
  CommentCont: function(e){
    this.setData({
      CommentCont: e.detail.value
    })
  },

  // 点击评论
  Comment: function(){
    var CommentCont = this.data.CommentCont;
    if (CommentCont == '' || CommentCont == null){
      wx.showToast({
        title: '评论内容不能为空',
        icon: 'none',
        duration: 1500
      })
    }else{
      $.Ajax("api/comment", "POST", {
        type: 0,
        objId: this.data.Id,
        content: CommentCont
      }, function (res) {
        wx.showToast({
          title: res.m,
          icon: 'none',
          duration: 1500
        })
        if (res.s) {
          setTimeout(function(){
            wx.navigateBack({
              delta: 1
            })
          },2000)
        }
      })
    }
  }
})